@echo off
@title 编译cmake项目

set ANDROID_NDK=D:\dev\sdk\ndk\21.3.6528147
set ANDROID_SDK=D:\dev\sdk
set PROJECTROOT=%cd%

::配置
cmake . -DCMAKE_INSTALL_PREFIX=%PROJECTROOT%\install ^
	-H%PROJECTROOT%/cpp ^
	-B%PROJECTROOT%/.cxx/cmake/arm7Debug/armeabi-v7a ^
	-G"Ninja" ^
	-DANDROID_ABI=armeabi-v7a ^
	-DANDROID_NDK=%ANDROID_NDK% ^
	-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=%cd%/build/intermediates/cmake/arm7/debug/obj/armeabi-v7a ^
	-DCMAKE_BUILD_TYPE=Debug ^
	-DCMAKE_MAKE_PROGRAM=%ANDROID_SDK%/cmake/3.10.2.4988404/bin/ninja.exe ^
	-DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%/build/cmake/android.toolchain.cmake ^
	-DANDROID_NATIVE_API_LEVEL=21 ^
	-DANDROID_TOOLCHAIN=clang
	
::编译
cmake --build %PROJECTROOT%/.cxx/cmake/arm7Debug/armeabi-v7a

::复制文件
if exist %PROJECTROOT%\libs (
	cd libs
    if not exist %PROJECTROOT%\libs\armeabi-v7a (
        mkdir armeabi-v7a
    )
) else (
	mkdir libs
	cd libs
	mkdir armeabi-v7a
)

cd %PROJECTROOT%
cp %PROJECTROOT%/.cxx/cmake/arm7Debug/armeabi-v7a/helloCmake %PROJECTROOT%/libs/armeabi-v7a/